package org.jeecg.modules.simulator.factory;

import lombok.Getter;
import lombok.Setter;
import org.jeecg.modules.simulator.model.SceneParam;
import org.jeecg.modules.simulator.model.line.station.station.Station;
import org.jeecg.modules.simulator.model.line.station.station.TransferStation;
import org.jeecg.modules.simulator.model.train.timeplan.TrainPlanTable;
import org.jeecg.modules.simulator.service.HistoryBizTrainLoaderService;
import org.jeecg.modules.simulator.util.UnitCache;
import org.jeecg.modules.simulator.vo.VirtualTrainSchedularQueryCondition;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LoadAllDayTrainHistory implements LoadHistoryTrainData{
    HistoryBizTrainLoaderService historyBizTrainLoaderService;
public LoadAllDayTrainHistory(HistoryBizTrainLoaderService historyBizTrainLoaderService){
    this.historyBizTrainLoaderService=historyBizTrainLoaderService;
}
    //历史列车时刻表
    //时刻表
    @Getter
    Map<String, List<TrainPlanTable>> trainPlanTableMapByLine = new HashMap<>();
    @Override
    public void loadHistroyTrain(Map<String, Station> stationMap, Map<String, TransferStation> transferStationMap, String sceneCode) {


        SceneParam sceneparam = UnitCache.sceneParamMap.get(sceneCode);

        historyBizTrainLoaderService.stationMap = stationMap;
        historyBizTrainLoaderService.setTransferStationMap(transferStationMap);


        VirtualTrainSchedularQueryCondition virtualTrainSchedularQueryCondition = new VirtualTrainSchedularQueryCondition();
        virtualTrainSchedularQueryCondition.setDataDt(sceneparam.getSceneDate());
//        virtualTrainSchedularQueryCondition.setStartTime(sceneparam.getSceneDate()+" "+sceneparam.getStartTimeStr());
//        virtualTrainSchedularQueryCondition.setEndTime(sceneparam.getSceneDate()+" "+sceneparam.getEndTimeStr());
        historyBizTrainLoaderService.setIsAllDay(true);
        historyBizTrainLoaderService.setVirtualTrainSchedularQueryCondition(virtualTrainSchedularQueryCondition);
        historyBizTrainLoaderService.loadTimePlanData();

        trainPlanTableMapByLine = historyBizTrainLoaderService.getTrainPlanTableByLineMap();

    }

    @Override
    public Map<String, List<TrainPlanTable>> getTrainPlanTableMapByLine() {
        return trainPlanTableMapByLine;
    }
}
